home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Performance Co-Pilot 1.3
/
SGI Performance Co-Pilot 1.3.iso
/
dist6.4
/
pcp.idb
/
usr
/
sbin
/
pmgevctr.z
/
pmgevctr
Wrap
Text File
|
1997-04-03
|
11KB
|
488 lines
#!/bin/sh
#
# Copyright 1996, Silicon Graphics, Inc.
# ALL RIGHTS RESERVED
#
# UNPUBLISHED -- Rights reserved under the copyright laws of the United
# States. Use of a copyright notice is precautionary only and does not
# imply publication or disclosure.
#
# U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
# Use, duplication or disclosure by the Government is subject to restrictions
# as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
# in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
# in similar or successor clauses in the FAR, or the DOD or NASA FAR
# Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
# 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
#
# THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
# INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
# DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
# PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
# GRAPHICS, INC.
#
# $Id: pmgevctr.sh,v 2.1 1997/03/26 02:49:08 kenmcd Exp $
#
# Break up of code
# ----------------
#
# Get arguments
# get gadget arguments
# get pmgevctr arguments
# set remaining args as shell args
# Fix up option values
# Check the desired metrics
# Get required metric information (use tmp files as is useful)
# Print out configuration file using "here documents"
# Call /usr/sbin/pmgadgets with config file
#
tmp=/tmp/$$
trap "rm -f $tmp.*; exit" 0 1 2 3 15
rm -f $tmp.*
# ----------------------------------------------------------
# usage - print out the usage of program
# ----------------------------------------------------------
_usage()
{
echo "Usage: $prog [options] [site [site ...]]"
echo '
Options
-V verbose/diagnostic output
pmgadgets(1) options:'
_pmgadgets_usage
}
# ----------------------------------------------------------
# metric_err
# ----------------------------------------------------------
_metric_err()
{
msg=$1
if [ "$arch" ]
then
_pmgadgets_error "For archive \"$arch\": $msg"
else
_pmgadgets_error "For host \"$host\": $msg"
fi
}
# ----------------------------------------------------------
# metric_warn
# ----------------------------------------------------------
_metric_warn()
{
msg=$1
if [ "$arch" ]
then
_pmgadgets_warning "For archive \"$arch\": $msg"
else
_pmgadgets_warning "For host \"$host\": $msg"
fi
}
# ----------------------------------------------------------
# get_router_metric -
# Get the instances from the router metric
# Assumes $has_routers is initially true, may change it to false
# Create a $tmp.$metric.name file
# ----------------------------------------------------------
_get_router_metrics()
{
# metric = "send_util" OR "recv.total_util"
metric=$1
# create a tmp.$metric file for the output of pminfo
rm -f $tmp.$metric
# output metric instances
pminfo -f $info_opts $namespace hw.router.$metric > $tmp.$metric 2>&1
# ensure tmp.metric is likely to be ok
if grep 'inst .* value' $tmp.$metric > /dev/null
then
:
else
has_routers=false
fi
if [ $has_routers = true ]
then
# create a tmp.$metric.name for each instance name
# each line of form:
# inst [65792 or "router:1.1"] value 0
# output:
# "router:1.1"
rm -f $tmp.$metric.name
sed -e 's/\]//' $tmp.$metric \
| nawk '$1 == "inst" {print $4}' > $tmp.$metric.name
fi
}
# -------------------------------------------------------
# _print_router_leds -
# Print out the leds for each router for send and receive
#
# Uses const:
# wrap_around
# ledX_start
# ledX_gap
# ledY_gap
# led_width
# led_height
# Uses variables:
# ledX
# ledY
# -------------------------------------------------------
_print_router_leds()
{
# metric = "send_util" OR "recv.total_util"
metric=$1
names=`cat $tmp.$metric.name`
for name in $names
do
cat << EOF >> $tmp.conf
_led $ledX $ledY $led_width $led_height
_update 5.000000
_metric hw.router.$metric[$name]
_legend routerLegend
_actions routerActions
EOF
ledX=`expr $ledX + $ledX_gap`;
ledX_right=`expr $ledX + $led_width`
# start a new row if we run out of room
if [ $ledX_right -gt $wrap_around ]
then
ledX=$ledX_start
ledY=`expr $ledY + $ledY_gap`
fi
done # foreach name
}
# ----------------------------------------------------------
# --- Get arguments ---
. /usr/pcp/lib/pmgadgets-args
# default variables
verbose=false
has_evctrs=true
has_routers=true
_pmgadgets_args "$@"
if [ -n "$otherArgs" ]
then
while getopts "?V" c $otherArgs
do
case $c
in
V)
verbose=true
;;
'?')
_usage
exit 1
;;
esac
done
# set positional params to the non-option (no -) arguments
set -- $otherArgs
shift `expr $OPTIND - 1`
# if have some non-option arguments (e.g. filenames) then error
if [ $# -gt 0 ]
then
_usage
exit 1
fi
fi
# --- fix up host ---
if [ "$arch" ]
then
host=`pmdumplog -l $arch | awk '/^Performance/ {print $5}' | sed -e 's/,//g'`
[ ! "$host" ] && host="unknown host"
else
[ ! "$host" ] && host=`/usr/bsd/hostname`
fi
# --- setup some pminfo options ---
if [ "$arch" ]
then
info_opts="-a $arch"
else
info_opts="-h $host"
fi
# --- Check on metric availability ---
# check for r10k event counters
event_cntrs=\
"hw.r10kevctr.grad.fp \
hw.r10kevctr.pcache.imiss hw.r10kevctr.pcache.dmiss \
hw.r10kevctr.scache.imiss hw.r10kevctr.scache.dmiss \
hw.r10kevctr.tlb hw.r10kevctr.vcc \
"
# check if have event counter state metric then use it
value=`pminfo $info_opts $namespace hw.r10kevctr.state 2>&1`
if expr match "$value" ".*value.*" > /dev/null
then
state=`echo $value | awk '{print $2}`
case $state in
"-1")
_metric_err "No R10000 event counters found"
;;
"0")
_metric_err "All R10000 event counters disabled"
;;
# Otherwise must have some event counters to use, so no error
esac
else
# check out if in namespace
# 1st check locally
rm -f $tmp.cntrs
pminfo $namespace $event_cntrs > $tmp.cntrs 2>&1
error=`grep 'Error' $tmp.cntrs`
if [ "$error" ]
then
bad_metric=`echo $error | awk '{print $2}' | sed -e 's/://'`
_pmgadgets_error "$bad_metric is not available in local name space"
fi
rm -f $tmp.cntrs
pminfo $info_opts $namespace $event_cntrs > $tmp.cntrs 2>&1
error=`grep 'Error' $tmp.cntrs`
if [ "$error" ]
then
bad_metric=`echo $error | awk '{print $2}' | sed -e 's/://'`
_metric_err "$bad_metric is not available in name space"
fi
rm -f $tmp.cntrs
pminfo -f $info_opts $namespace $event_cntrs > $tmp.cntrs 2>&1
# check out if PMCD unable to help
error=`grep 'Unknown or illegal metric' $tmp.cntrs`
if [ "$error" ]
then
bad_metric=`echo $error | awk '{print $1}' | sed -e 's/://'`
_metric_err "PMCD does not support $bad_metric"
fi
error=`grep 'Metric not supported' $tmp.cntrs`
if [ "$error" ]
then
_metric_err "PMCD does not support R10000 event counters"
fi
# check out if cannot connect to PMCD
if grep 'Cannot connect to PMCD' $tmp.cntrs > /dev/null
then
_metric_err "Cannot connect to PMCD"
fi
# check for unavailability
if grep 'No value(s) available' $tmp.cntrs > /dev/null
then
_metric_warn "R10000 event counter(s) unavailable"
fi
# check for unavailability
if grep 'Information not currently available' $tmp.cntrs > /dev/null
then
_metric_warn "R10000 event counter(s) unavailable"
fi
fi
# --- Get instance information from metrics ---
[ $has_routers = true ] && _get_router_metrics "send_util"
[ $has_routers = true ] && _get_router_metrics "recv.total_util"
# ----------------------------------------------------------
# --- Output the config file ---
cat << EOF >> $tmp.conf
_label 5 9 $host
_label 5 20 "CPU"
_colourlist cpuColours (blue3 red3 yellow3 cyan3 green3)
_multibar 5 22 55 6
_update 5.000000
_metrics (
irix.kernel.all.cpu.user
irix.kernel.all.cpu.sys
irix.kernel.all.cpu.intr
irix.kernel.all.cpu.wait.total
irix.kernel.all.cpu.idle
)
_maximum 0.0
_colourlist cpuColours
_label 5 38 "Load"
_bargraph 5 39 55 30
_update 5.000000
_metric irix.kernel.all.load["1 minute"]
_max 1.0
_label 5 79 "Free Mem"
_bar 5 81 55 6
_update 5.000000
_metric irix.mem.freemem
_max 6442450944
_color blue
EOF
# ----------------------------------------------------------
if [ $has_evctrs = true ]
then
cat << EOF >> $tmp.conf
_label 75 20 "Events"
_colourlist eventColors ( "rgbi:0.3/0.0/1.0" "rgbi:1.0/0.9/0.0" )
_bar 75 22 45 6
_update 5.000000
_metric hw.r10kevctr.grad.fp
_colour green
_label 122 27 "mflop"
_multibar 75 32 45 6
_update 5.000000
_metrics (
hw.r10kevctr.pcache.imiss
hw.r10kevctr.pcache.dmiss
)
_colourlist eventColors
_label 122 37 "1$ miss"
_multibar 75 42 45 6
_update 5.000000
_metrics (
hw.r10kevctr.scache.imiss
hw.r10kevctr.scache.dmiss
)
_colourlist eventColors
_label 122 47 "2$ miss"
_multibar 75 52 45 6
_update 5.000000
_metrics (
hw.r10kevctr.tlb
hw.r10kevctr.vcc
)
_colourlist eventColors
_label 122 57 "tlb/vcc"
_bar 75 62 45 6
_update 5.000000
_metric irix.swap.pagesout
_color red
_label 122 67 "pageout"
EOF
fi # has r10K
# ----------------------------------------------------------
# --- Router check ---
if [ $has_routers = true ]
then
cat << EOF >> $tmp.conf
_actions routerActions (
"pmchart" "pmchart -c /var/pcp/config/pmchart/Disk -h $host"
"dkvis *" "dkvis -h $host" _default
)
_label 5 98 "Router Util"
_actions routerActions
_legend routerLegend (
_default green3
5 yellow
10 orange
20 red
)
EOF
# router coordinates
# Wraparound is for when to go down to next row of leds
# Really need to know the width of a label
wrap_around=170
routerX=5
ledX_start=32
ledY_start=102
ledX_gap=10
ledY_gap=10
led_width=7
led_height=7
readonly routerX
readonly wrap_around
readonly ledX_start
readonly ledY_start
readonly ledX_gap
readonly ledY_gap
readonly led_width
readonly led_height
ledX=$ledX_start
ledY=$ledY_start
labelY=`expr $ledY + 6`
cat << EOF >> $tmp.conf
_label $routerX $labelY "send"
EOF
_print_router_leds send_util
ledX=$ledX_start
ledY=`expr $ledY + $ledY_gap`
labelY=`expr $ledY + 6`
cat << EOF >> $tmp.conf
_label $routerX $labelY "recv"
EOF
_print_router_leds recv.total_util
fi # has routers
$verbose && cat $tmp.conf
eval /usr/sbin/pmgadgets <$tmp.conf $args -xrm "'*iconName: pmgevctr'"